/* Ejercicio 4.33: ejer4_33.c
   Roman Numeral Equivalent of decimal values */
#include <stdio.h>

/* function main begins program execution */
int main( void )
{
   int i;
   int digit;

   printf( "Decimal\tRoman\n" );
   for ( i = 1; i <= 100; i++ ) {

      printf( "%d\t", i );
      /* Centesimas */
      digit = i / 100;

      switch( digit ) {
         case 1:
            printf( "C" );
            break;
      }

      /* Decenas */
      digit = ( i % 100 ) / 10;

      switch( digit ) {
         case 0:
            break;
         case 1:
            printf( "X" );
            break;
         case 2:
            printf( "XX" );
            break;
         case 3:
            printf( "XXX" );
            break;
         case 4:
            printf( "XL" );
            break;
         case 5:
            printf( "L" );
            break;
         case 6:
            printf( "LX" );
            break;
         case 7:
            printf( "LXX" );
            break;
         case 8:
            printf( "LXXX" );
            break;
         case 9:
            printf( "XC" );
            break;
      }

      /* Unidades */
      digit = i % 10;

      switch( digit ) {
         case 0:
            break;
         case 1:
            printf( "I" );
            break;
         case 2:
            printf( "II" );
            break;
         case 3:
            printf( "III" );
            break;
         case 4:
            printf( "IV" );
            break;
         case 5:
            printf( "V" );
            break;
         case 6:
            printf( "VI" );
            break;
         case 7:
            printf( "VII" );
            break;
         case 8:
            printf( "VIII" );
            break;
         case 9:
            printf( "IX" );
            break;
      }

      printf( "\n" );
   }
	return 0; /* indicate that program ended successfully */
} /* end function main */
